import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [vue(),],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    css: {
        preprocessorOptions: {
            scss: {
                additionalData: `
                    @use "@/assets/styles/variables" as *;
                    @use "@/assets/styles/mixins" as *;
                    `,
            },
        },
    },
    server: {
        proxy: {
            '/api': {//获取路径中包含了/api的请求
                target:'http://localhost:8080',//后台服务所在源
                // target: "https://a3d9e22c-0f79-4fec-b87b-4e0191763154.mock.pstmn.io",//后台服务所在源
                changeOrigin: true,//修改源
                rewrite: (path) => path.replace(/^\/api/, '')//'/api'替换成''
            }
        }
    }
})
